package de.puc.defencetower.model;

import java.util.ArrayList;
import java.util.List;


public abstract class Tower extends MapElement {

	public static final int TOWERTYPE_SMALL = 0;
	public static final int TOWERTYPE_MIDDLE = 1;
	public static final int TOWERTYPE_BIG = 2;

	private boolean shooting;

	private int range;
	private int shootFreq;
	private int shootTime;
	private List<MapCell> streetsInShootRange;
	private double damage;
	private int goldCosts;
	private int level;
	private int goldCostsUpgrade;

	public Tower(int range, int shootFreq, int shootTime, double damage, int goldCosts, int goldCostsUpgrade) {
		this.range = range;
		this.shootFreq = shootFreq;
		this.shootTime = shootTime;
		this.damage = damage;
		this.goldCosts = goldCosts;
		this.goldCostsUpgrade = goldCostsUpgrade;
		this.shooting = false;
		level = 0;
	}

	/**
	 * Muss vor dem bauen gesetzt werden.
	 * 
	 * @param streetsInRange
	 */
	public void setStreetsInRange(List<MapCell> streetsInRange) {
		streetsInShootRange = streetsInRange;
	}

	public List<Monster> getMonstersInRange() {
		ArrayList<Monster> array = new ArrayList<Monster>();

		for (MapCell mc : streetsInShootRange) {
			for (MapElement me : mc.getMapElements()) {
				if (me instanceof Monster) {
					array.add((Monster) me);
				}
			}
		}
		return array;
	}

	public double getDamage() {
		return damage;
	}

	public int getRange() {
		return range;
	}

	public int getShootFreq() {
		return shootFreq;
	}

	public int getShootTime() {
		return shootTime;
	}

	public boolean isShooting() {
		return shooting;
	}

	public void setShooting(boolean shooting) {
		this.shooting = shooting;
	}

	public int getGoldCosts() {
		return goldCosts;
	}
	
	public int getGoldCostsUpgrade() {
		return goldCostsUpgrade;
	}

	public abstract int getType();

	public int getLevel() {
		return level;
	}

	public void upgrade(){
		level++;
		damage *= 4/3;
		
	}
	

}
